<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="../../js/mui.min.js"></script>
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="../../css/mui.min.css">
		<link rel="stylesheet" href="../../css/global.css">
		<link rel="stylesheet" type="text/css" href="../../css/app.css" />
		<script src="../../js/getURLParam.js"></script>
		<script type="text/javascript" charset="UTF-8">

		</script>
	</head>

	<body>
		<!--<header class="mui-bar mui-bar-nav  headerstyle">
			<a class="mui-action-back astyle"><img src="../../images/drawable-hdpi/head_back.png"/></a>
			<h1 id="title" class="mui-title">密码修改</h1>
		</header>-->
		<div class="mui-content" style="padding-top: 10px;">
			<p style="margin: 5px;">请设置新密码，设置成功后，网站和手机APP同步生效。</p>
			<p style="margin: 5px;">密码规则：必须包含数字、字母和特殊符号，且长度不能小于8位</p>

			<form class="mui-input-group fongtstyle" style="margin-top: 10px;">
				<div class="mui-input-row">
					<label for="">原密码：</label>
					<input type="password" class="mui-input mui-input-clear" id="old_pass" placeholder="请输入原密码" />
				</div>
				<div class="mui-input-row">
					<label for="">新密码：</label>
					<input type="password" class="mui-input mui-input-clear" id="new_pass" placeholder="请输入新密码" onblur="new_passfun();" />
				</div>
				<div class="mui-input-row">
					<label for="">确认密码：</label>
					<input type="password" class="mui-input mui-input-clear" id="makesure_pass" placeholder="请确认新密码"  />
				</div>
			</form>
			<br />
			<div class="mui-content-padded" style="margin: 0px;">
				<button type="button" class="mui-btn mui-btn-block mui-btn-primary" onclick="saveS()" >完成</button>
			</div>
		</div>
	</body>
	<script src="../../js/mui.min.js"></script>
	<script type="text/javascript">
		mui.init();
		//判断新密码的安全性
		function new_passfun() {
			var new_pass_input = document.getElementById("new_pass").value;
			var new_pass = document.getElementById("new_pass");
			if (new_pass.value.length > 0) {
				//判断长度是否小于8位
				if (new_pass.value.length < 8) {
					mui.toast('密码长度不得小于8位');
					return;
				}
				//判断是否包含数字
				var re1 = new RegExp("[a-zA-Z]");
				var len1 = re1.test(new_pass_input);
				if (!len1) {
					mui.toast('必须包含字母');
					return false;
				}
				var re2 = new RegExp("[0-9]");
				var len2 = re2.test(new_pass_input);
				if (!len2) {
					mui.toast('必须包含数字');
					return false;
				}
				var re3 = new RegExp("((?=[\x21-\x7e]+)[^A-Za-z0-9])");
				var len3 = re3.test(new_pass_input);
				if (!len3) {
					mui.toast('必须包含特殊符号');
					return false;
				}
			}
		}
		//判断'新密码'和'确认密码'是否一致
		function ifOrNotSame() {
			var new_pass_input = document.getElementById("new_pass").value;
			var makesure_pass_input = document.getElementById("makesure_pass").value;
			if (new_pass_input != makesure_pass_input) {
				mui.toast('密码不一致， 请重新输入');
				// 清空输入框
				document.getElementById("makesure_pass").value = "";
				document.getElementById("new_pass").value = "";
			}
		}
	
			var sessionid=GetQueryString("sessionid");
	        var proVersion = GetQueryString("proVersion");
	        var accountId = GetQueryString("accountId");
			function saveS(){
				var password=document.getElementById("old_pass").value;;//旧密码
	      		var newPassword=document.getElementById("new_pass").value;//新密码
	      		if(""==password||null==password){
	      			mui.toast("请输入原密码！");
	      			return;
	      		}
	      		if(newPassword==""||null==newPassword){
	      			mui.toast('请输入新密码！');
	      			return;
	      		}
	      		
	      	if (newPassword.length > 0) {
				//判断长度是否小于8位
				if (newPassword.length < 8) {
					mui.toast('密码长度不得小于8位');
					return;
				}
				//判断是否包含数字
				var re1 = new RegExp("[a-zA-Z]");
				var len1 = re1.test(newPassword);
				if (!len1) {
					mui.toast('必须包含字母');
					return false;
				}
				var re2 = new RegExp("[0-9]");
				var len2 = re2.test(newPassword);
				if (!len2) {
					mui.toast('必须包含数字');
					return false;
				}
				var re3 = new RegExp("((?=[\x21-\x7e]+)[^A-Za-z0-9])");
				var len3 = re3.test(newPassword);
				if (!len3) {
					mui.toast('必须包含特殊符号');
					return false;
				}
			}
	      		
	      		var makesure_pass_input = document.getElementById("makesure_pass").value;
	      		if (newPassword != makesure_pass_input) {
				mui.toast('密码不一致， 请重新输入');
				// 清空输入框
				document.getElementById("makesure_pass").value = "";
				document.getElementById("new_pass").value = "";
				return;
			}
				mui.ajax('../../../APP/chanPassword',{ 
					//mui.ajax('../../../APP/chanPassword',{ 
				data:{param:'{"proVersion":"'+proVersion+'","accountId":"'+accountId+'","sessionid":"'+sessionid+'","data":{"password":"'+password+'","newPassword":"'+newPassword+'"}}'},
				dataType:'jsonp',//服务器返回json格式数据
				type:'post',//HTTP请求类型
				timeout:10000,//超时时间设置为10秒；
				success:function(data){
					var jsonObj = window.JSON.parse(data);
					if(jsonObj.resultCode=="1"){
						mui.toast('修改密码成功');
						window.webkit.messageHandlers.savePassWord.postMessage("1");
					}else if(jsonObj.resultCode=="143"){
						mui.toast('原密码不正确');
					}else{
						mui.toast('修改密码失败');
					}
					
				}
				
			});
		}
		function gotoback(){
				mui.back();
			}
	</script>

</html>